All Questions
114 questions
0votes
1answer
82views
cleaning up full directories at once
right now, i have a filesystem that fills up fairly regularly. the TL;DR is that I can't introduce better log rotation, and the files must be deleted regularly. let's say i have the following output ...
0votes
0answers
50views
list all the lines of an output that are not in the contents of another file
I have a directory of files. I want to check which of these files are not listed in the contents of another file, (content.txt). content.txt contains the file names, but also contains some text before ...
0votes
2answers
679views
Replace multiple lines and words using sed in a for loop
I have 2 files (mac and uid) with data on a Linux machine, that I want to carry to a "template", with a list, using sed to replace the data with variables. list.txt: CP00 CP01 mac.txt: FF-...
1vote
2answers
40views
How to match the starting of string & then replace some value using the pattern in bash
vm0 host=10.182.35.1 controller=True vm1 host=10.182.35.2 controller=False solution=abc vm2 host=10.182.35.3 controller=True solution=abc vm3 host=10.182.37.4 controller=False solution=xyz vm4 host=10....
0votes
1answer
110views
uncomment the line upon search string while ignoring case in a file
Below is my cron file entries: #Ansible: test2 */15 * * * * ansible-playbook /web/playbooks/automation/detect401MORTEN/va_action.yml | tee -a /web/playbooks/automation/detect401MORTEN/cron.out # #...
0votes
1answer
112views
Inserting and updating a block of code at the end of a file
So I have a file which looks like the following #ifndef CONFIG_DHCP_H #define CONFIG_DHCP_H FILE_LICENCE(GPL2_OR_LATER_OR_UBDL); #include <config/defaults.h> #define ...
1vote
1answer
265views
sed -i command issue with '
I am trying to edit a line in a large text file using the sed command in linux. The original line from my file.txt is: Cg64_2043 XI1.MM1.GATE vss '0.0' I essentially want to change the 0.0 in the ...
-1votes
5answers
882views
How to make sure that the last character of each line of a file ends with single quote character
I have a file which has several lines. I wish to update the file while making sure that the last visible character of each line of the file is a single quote '. In case not, then we should add the ...
0votes
1answer
1kviews
How to add single quote at the end of ONLY the last line of a file [duplicate]
I want a non-perl solution where I should be able to append a single quote ' at the last visible (non-escape characters) line of a file and save it back to the file. cat example.txt var1: 'funn' var2: ...
0votes
1answer
836views
Only perform sed operations on lines starting with a particular string [closed]
I have the following file format Received from +11231231234 at 2021-10-10T19:56:50-07:00: This is a message that contains words like from, at, etc. Sent to +11231231234 at 2021-10-11T06:50:57+00:00: ...
-1votes
2answers
65views
Help with sed command [duplicate]
I need a sed command that will allow me to search for and display the info for all games released in the 1980's and alphabetize those results. Is there a good way to do this with only using sed? 1 ...
0votes
2answers
1kviews
Replace specified strings in file with strings from other file with sed [duplicate]
I have two files like this. file1 line 1 line 2 ... (more lines) aaa PLACEHOLDER bbb ccc ... (more lines) ddd PLACEHOLDER eee fff ... (more lines) etc file2 NEWTEXT1 NEWTEXT2 ... (more lines) There ...
0votes
4answers
2kviews
Splitting a line in a file into two columns
I want to split a line into two coloumns ./ABC/dce/app/config/fgh/pqr/app.properties:app.pass=***** I want the colon(:) in the above line as seperator and output like below ./ABC/dce/app/config/fgh/...
-1votes
2answers
76views
sed command succesfuly find and replace in file , bit erasing everything in the new file
i have this xml text in file named test2.txt <This is a line of text with a year=2020 month=12 in it This line of text does not have a year or month in it This year=2021 is the current year the ...
1vote
1answer
798views
Rename hundreds of filenames to replace or delete specific words including duplicated words via MacOS Terminal (bash/sh/zsh?)
Summary I have thousands of pictures that were titled in full sentences. I am trying to automate a way to do clean them up with a single script, and then reuse that script as I add more pictures. The ...